package source;

import javax.servlet.http.HttpSession;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

import entity.Admin;
import entity.User;

import java.io.*;

/**
 * This simple tag implements header.
 * 
 * @author Qiu Zekang
 *
 */
public class AdminPageHeaderTag extends TagSupport {
	/**
	 * 
	 */
	

	/**
	 * Rewrite doTag method to implement show footer in .JSP
	 * 
	 *
	 */
	public int doStartTag() throws JspException {

	JspWriter out = pageContext.getOut();
	HttpSession session = pageContext.getSession();
	
	String admin_name = "管理员";
	Admin admin = (Admin) session.getAttribute("admin");
	if(admin!=null) {
		 admin_name = admin.getAdmin_name();
	}
	String hh="\r\n";
	
	String outPrint = 
					"<div class=\"header\">"+hh+
					"<div class=\"container\">"+hh+
					"<div class=\"row\">"+hh+
					"<div class=\"col-md-5\">"+hh+
					"<div class=\"logo\">"+hh+
					"<h1 style=\"color:white\">Admin Page</h1>"+hh+
					"</div>"+hh+
					"</div>"+hh+
					"<div class=\"col-md-5\">"+hh+
					"<div class=\"row\">"+hh+
					"<div class=\"col-lg-12\">"+hh+
					"</div>"+hh+
					"</div>"+hh+
					"</div>"+hh+
					"<div class=\"col-md-2\">"+hh+
					"<div class=\"navbar navbar-inverse\" role=\"banner\">"+hh+
					"<nav class=\"collapse navbar-collapse bs-navbar-collapse navbar-right\" role=\"navigation\">"+hh+
					"<br>"+hh+
					"<span style=\"color:white\">你好,"+admin_name+"!&nbsp;&nbsp;&nbsp;</span>"+hh+
					"<a href=\"Admin_LogOut_Servlet\"  style=\"color:red\">退出登陆</a>"+hh+
					"</nav>"+hh+
					"</div>"+hh+
					"</div>"+hh+
					"</div>"+hh+
					"</div>"+hh+
					"</div>";			
		try {
			out.print(outPrint);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return SKIP_BODY;
	}
}
